package com.rbcs.borrow.webapp.cell;



import java.text.ParseException;
import java.util.Date;

import org.ecside.core.TableModel;
import org.ecside.core.bean.Column;
import org.ecside.table.cell.AbstractCell;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.systop.core.util.DateUtil;


public class IntervalDayCell extends AbstractCell {

  protected Logger logger = LoggerFactory.getLogger(getClass());

  /**
   * 获取借款日期与当前系统日期之间相差的天数
   */
  @Override
  protected String getCellValue(TableModel model, Column col) {
    Object obj = col.getPropertyValue();
    if(obj == null) {
      return  null;
    }
    //Date borrowDate = (Date) obj;
    //Long intervalDay = DateUtil.getIntervalDay(borrowDate, new Date());
		try {
			Date borrowDate = DateUtil.convertStringToDate("yyyy-MM-dd", obj.toString());
		  Long intervalDay = DateUtil.getIntervalDay(borrowDate, DateUtil.getCurrentDate());
	    return intervalDay.toString() + " 天";
		} catch (ParseException e) {
			e.printStackTrace();
		}
    return null;
  }

}
